package com.changgou.search.listener;

import com.changgou.search.config.RabbitMQConfig;
import com.changgou.search.service.ESManagerService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author kfzhao
 * @version 1.0
 * @className GoodsUpListener
 * @description
 * @date 2021/12/27 23:18
 */
@Component
public class GoodsUpListener {
    @Autowired
    private ESManagerService esManagerService;

    /**
     * 监听方法，监听改变的spuId
     * @param spuId
     * @return void
     * @throws
     * @description
     * @author kfzhao
     * @date 2021/12/27 23:18
     */
    @RabbitListener(queues = RabbitMQConfig.SEARCH_ADD_QUEUE)
    public void receiveMessage(String spuId) {
        System.out.println("接收到的消息为 " + spuId);
        // 查询skuList 并导入到索引库
        esManagerService.importDataBySpuId(spuId);
    }
}
